/**
 * Created by shaotingzhou on 2017/5/17.
 */
import React, { Component } from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    ListView,
    Image,
    TouchableOpacity,
    Platform,
    Dimensions,
    RefreshControl
} from 'react-native';
import Navigator from '../../../Main/navigator'
import Item from './orderDetailsItem'
var {width,height} = Dimensions.get('window');
let dataAry = [1,2,3,4,5]
var ds = new ListView.DataSource({rowHasChanged:(r1,r2) => r1 !== r2});
export default class OrderDetails extends Component{
    // 构造
    constructor(props) {
        super(props);
        // 初始状态
        this.state = {
            dataSource: ds.cloneWithRows(dataAry),
            isRefreshing:true
        };
    }
    render() {
        return (
            <View style={{flex:1,backgroundColor:'#f5f5f5'}}>
                {/*导航栏*/}
                <Navigator
                    centerText = '订单详情'
                    leftSource={require('../../../image/返回.png')}
                    leftAction = {()=>this.leftAction()}
                    rightAction = {() => this.rightAction()}
                />
                {/*付款人+付款日期*/}
                <View style={{backgroundColor:'rgba(156,204,101,1.0)',height:100}}>
                    <Text style={{fontWeight:'bold',marginLeft:5,marginTop:15,fontSize:16,color:'white'}}>付款人: 华纳唱片</Text>
                    <Text style={{fontWeight:'bold',marginLeft:5,marginTop:10,fontSize:16,color:'white'}}>付款日期: 2017.04.11 11:23:22</Text>
                </View>
                {/*合同*/}
                    <ListView
                        style={{marginTop:-15}}
                        dataSource={this.state.dataSource}
                        renderRow={this.renderRow}
                        enableEmptySections={true}  //去除警告
                        refreshControl={
                            <RefreshControl
                                refreshing={this.state.isRefreshing}
                                onRefresh={()=>this.onRefreshData()}
                            />
                        }
                    />

            </View>
        );
    }

    leftAction =()=>{
        this.props.navigator.pop({})
    }

    rightAction =()=>{

    }

    //listView的renderRow
    renderRow =(rowData,sectionID,rowID,highlightRow) =>{
        return(
            <Item rowData = {rowData} navigator={this.props.navigator}/>
        )
    }
    //请求数据
    componentDidMount(){
        this.setState({
            isRefreshing:false
        })
    }
    //刷新数据
    onRefreshData =()=>{

    }
};


var styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#F5FCFF',
    },
    welcome: {
        fontSize: 20,
        textAlign: 'center',
        margin: 10,
    },
    instructions: {
        textAlign: 'center',
        color: '#333333',
        marginBottom: 5,
    }
});

